<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Controlador de la pagina de inicio ( login ) , manejara los metodos de login y logout
 * 
 */
class Home extends CI_Controller {

	public function index()
	{
		$this->load->view('home');
	}
	public function login()
	{
		$this->load->library('usuario',array('userName'=>$this->input->post('user',true),
				'password'=>$this->input->post('pass',true)));
		
		if($this->usuario->getIdUsuarios()!='')
		{
			$newdata = $this->usuario->getArray();
			$this->session->set_userdata($newdata);
			echo '<script type="text/javascript">
			window.location = "'.base_url().'catalogo"</script>';
		}
		else
		{
			echo '<script type="text/javascript">
			window.location = "'.base_url().'"</script>';
		}
		
		
	}
	public function logout()
	{
		$array_items = array(
                   'userName'  => '',
                   'idUsuarios'     => '',
                   'password' => '',
				   'nombre'=>'',
				   'email'=>'',
					'direccion' => '',
					'fechaNacimiento'=>'',
					'sexo'=>''
               		);
		$this->session->unset_userdata($array_items);
		echo '<script type="text/javascript">
		window.location = "'.base_url().'"</script>';
	}
	
}
?>